local xiaocheng_active = fk.CreateSkill({
  name = "hanqing__xiaocheng&",
})

Fk:loadTranslationTable{
  ["hanqing__xiaocheng&"] = "孝成",
  [":hanqing__xiaocheng&"] = "出牌阶段限一次，你可以交给赵丹两张牌并获得其装备区一张牌，若你为赵势力，则改为区域内一张牌。",

  ["#hanqing__xiaocheng&"] = "孝成：交给赵丹两张牌并获得其装备区一张牌，若你为赵势力则改为获得其区域内一张牌",
  ["#hanqing__xiaocheng-prey"] = "孝成：获得 %dest 一张牌",
  ["#hanqing__xiaocheng-equip"] = "孝成：获得 %dest 一张装备",
}

xiaocheng_active:addEffect("active", {
  mute = true,
  prompt = "#hanqing__xiaocheng&",
  card_num = 2,
  target_num = 1,
  can_use = function (self, player)
    return table.find(Fk:currentRoom().alive_players, function (p)
      return p:hasSkill("hanqing__xiaocheng") and p ~= player and
      p:usedSkillTimes("hanqing__xiaocheng", Player.HistoryPhase) == 0
    end)
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected < 2
  end,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select:hasSkill("hanqing__xiaocheng") and
      to_select:usedSkillTimes("hanqing__xiaocheng", Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    target:addSkillUseHistory("hanqing__xiaocheng", 1)
    target:broadcastSkillInvoke("hanqing__xiaocheng")
    room:notifySkillInvoked(target, "hanqing__xiaocheng", "support")
    room:moveCardTo(effect.cards, Card.PlayerHand, target, fk.ReasonGive, "hanqing__xiaocheng", nil, false, player)
    if player.dead or target.dead then return end
    local card = 0
    if player.kingdom == "zhao" then
      if target:isAllNude() then return end
      card = room:askToChooseCard(player, {
        target = target,
        flag = "hej",
        skill_name = xiaocheng_active.name,
        prompt = "#hanqing__xiaocheng-prey::"..target.id,
      })
    else
      if #target:getCardIds("e") == 0 then return end
      card = room:askToChooseCard(player, {
        target = target,
        flag = "e",
        skill_name = xiaocheng_active.name,
        prompt = "#hanqing__xiaocheng-equip::"..target.id,
      })
    end
    room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, "hanqing__xiaocheng", nil, false, player)
  end,
})

return xiaocheng_active
